app.controller('passController', function ($scope, $rootScope, $http, $interval, $compile,$state) {
    //修改密码
    $scope.change = function () {
        if(!$scope.validData()){
            return;
        }
        var reqeustData = $scope.user;
        postHttp($http, 'updatePassword', reqeustData, function (res) {
            if (res.msg === 'success') {
                $rootScope.tipPopups.show(($rootScope.tipMessage = "修改成功!"));

                // $state.go(mine.stateName);
            } else {
                $rootScope.tipPopups.show(($rootScope.tipMessage = res.msg));
            }
        });
    }

    //非空验证
    $scope.validData = function () {
        if (!$scope.user.username) {
            $rootScope.tipMessage = '邮箱为空'
            $rootScope.tipPopups.show({closeFlag:false});
            return false;
        }
        if (!$scope.user.oldPassword) {
            $rootScope.tipPopups.show(($rootScope.tipMessage = '旧密码为空'));
            return false;
        }
        if (!$scope.user.password) {
            $rootScope.tipPopups.show(($rootScope.tipMessage = '新密码为空'));
            return false;
        }
        return true;
    }

    function init(){
        //初始化input插件
        document.title='修改密码';
        var username = sessionStorage.getItem("username");
        $scope.user = {
            username:username
        };
    }

    init();
    reloadJs();
});